<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./utils.js"></script>
  <script src="./dep.js"></script>
  <script src="./watcher.js"></script>
  <script src="./compiler.js"></script>
  <script src="./observer.js"></script>
  <script src="./vue.js"></script>

</head>

<body>
  <style>
    .highlight {
      color: red;
    }

  </style>

  <div id="app">
    <div>
      <span v-text="msg" v-bind:class="dynamicClass"></span>
      {{ name }}
      {{ age }}
    </div>
    <input v-model="name" type="text" />
    <input v-model="age" type="number" />
    <button v-on:click="handleAuth">{{ btnText }}</button>

    <hr />
    <div v-show="auth">
      <textarea v-model="msg"></textarea>
      <button v-on:click="handleClick" v-bind:class="dynamicClass">Change Color</button>
    </div>
  </div>

</body>
<script>
  const app = new Vue({
    el: '#app',
    data: {
      msg: 'Hello World',
      name: 'zpj',
      age: 21,

      dynamicClass: 'highlight',
      auth: false,
      btnText: 'Login'
    },
    methods: {
      handleClick() {
        this.dynamicClass = this.dynamicClass === 'highlight' ? '' : 'highlight';
      },
      handleAuth() {
        this.auth = !this.auth;
        this.btnText = this.auth ? 'Logout' : 'Login';
      }
    },
  })

</script>

</html>
